home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / dpmi.inc < prev    next >
Encoding:
Text File  |  1997-01-16  |  9.3 KB  |  307 lines

  1. ;*      DPMI.INC
  2. ;*
  3. ;* DPMI functions for protected mode MIDAS
  4. ;*
  5. ;* $Id: dpmi.inc,v 1.3 1997/01/16 18:41:59 pekangas Exp $
  6. ;*
  7. ;* Copyright 1996,1997 Housemarque Inc.
  8. ;*
  9. ;* This file is part of the MIDAS Sound System, and may only be
  10. ;* used, modified and distributed under the terms of the MIDAS
  11. ;* Sound System license, LICENSE.TXT. By continuing to use,
  12. ;* modify or distribute this file you indicate that you have
  13. ;* read the license and understand and accept it fully.
  14. ;*
  15.  
  16.  
  17. ;/***************************************************************************\
  18. ;*       struct dpmiRealCallRegs
  19. ;*       -----------------------
  20. ;* Description:  Real mode calling register value structure
  21. ;\***************************************************************************/
  22.  
  23. STRUC   dpmiRealCallRegs
  24.         rEDI            DD      ?
  25.         rESI            DD      ?
  26.         rEBP            DD      ?
  27.         reserved        DD      ?
  28.         rEBX            DD      ?
  29.         rEDX            DD      ?
  30.         rECX            DD      ?
  31.         rEAX            DD      ?
  32.         flags           DW      ?
  33.         rES             DW      ?
  34.         rDS             DW      ?
  35.         rFS             DW      ?
  36.         rGS             DW      ?
  37.         rIP             DW      ?
  38.         rCS             DW      ?
  39.         rSP             DW      ?       ; if SS and SP are zero, DPMI will
  40.         rSS             DW      ?       ; provide a small (30 words) stack
  41. ENDS
  42.  
  43.  
  44.  
  45.  
  46. ;/***************************************************************************\
  47. ;*
  48. ;* Function:    int dpmiAllocDescriptor(unsigned *descriptor);
  49. ;*
  50. ;* Description: Allocate LDT descriptor. Use dpmiFreeDescriptor to deallocate.
  51. ;*
  52. ;* Input:       unsigned *descriptor    pointer to descriptor number
  53. ;*
  54. ;* Returns:     MIDAS error code. Descriptor number is written to *descriptor.
  55. ;*
  56. ;\***************************************************************************/
  57.  
  58. GLOBAL  LANG dpmiAllocDescriptor : _funct
  59.  
  60.  
  61.  
  62.  
  63. ;/***************************************************************************\
  64. ;*
  65. ;* Function:    int dpmiFreeDescriptor(unsigned descriptor);
  66. ;*
  67. ;* Description: Deallocates an LDT descriptor.
  68. ;*
  69. ;* Input:       unsigned descriptor     descriptor to deallocate
  70. ;*
  71. ;* Returns:     MIDAS error code
  72. ;*
  73. ;\***************************************************************************/
  74.  
  75. GLOBAL  LANG dpmiFreeDescriptor : _funct
  76.  
  77.  
  78.  
  79.  
  80. ;/***************************************************************************\
  81. ;*
  82. ;* Function:    int dpmiSetSegmentBase(unsigned selector, ulong baseAddr);
  83. ;*
  84. ;* Description: Changes the 32-bit linear base address of a selector.
  85. ;*
  86. ;* Input:       unsigned selector       selector number
  87. ;*              ulong baseAddr          32-bit linear base address for
  88. ;*                                      selector
  89. ;*
  90. ;* Returns:     MIDAS error code.
  91. ;*
  92. ;\***************************************************************************/
  93.  
  94. GLOBAL  LANG dpmiSetSegmentBase : _funct
  95.  
  96.  
  97.  
  98.  
  99. ;/***************************************************************************\
  100. ;*
  101. ;* Function:    int dpmiGetSegmentBase(unsigned selector, ulong *baseAddr);
  102. ;*
  103. ;* Description: Reads the 32-bit linear base address of a selector.
  104. ;*
  105. ;* Input:       unsigned selector       selector number
  106. ;*              ulong *baseAddr         pointer to the 32-bit linear base
  107. ;*                                      address of the selector
  108. ;*
  109. ;* Returns:     MIDAS error code. Selector base address is written to
  110. ;*              *baseAddr.
  111. ;*
  112. ;\***************************************************************************/
  113.  
  114. GLOBAL LANG dpmiGetSegmentBase : _funct
  115.  
  116.  
  117.  
  118.  
  119. ;/***************************************************************************\
  120. ;*
  121. ;* Function:    int dpmiSetSegmentLimit(unsigned selector, ulong limit);
  122. ;*
  123. ;* Description: Changes the limit of a segment selector.
  124. ;*
  125. ;* Input:       unsigned selector       selector number
  126. ;*              ulong limit             32-bit segment limit
  127. ;*
  128. ;* Returns:     MIDAS error code.
  129. ;*
  130. ;\***************************************************************************/
  131.  
  132. GLOBAL  LANG dpmiSetSegmentLimit : _funct
  133.  
  134.  
  135.  
  136.  
  137. ;/***************************************************************************\
  138. ;*
  139. ;* Function:    int dpmiSetSegmentAccessRights(unsigned selector,
  140. ;*                  unsigned accessRights);
  141. ;*
  142. ;* Description: Changes the access rights of a selector
  143. ;*
  144. ;* Input:       unsigned selector       selector
  145. ;*              unsigned accessRights   new access rights for the segment
  146. ;*
  147. ;* Returns:     MIDAS error code.
  148. ;*
  149. ;\***************************************************************************/
  150.  
  151. GLOBAL  LANG dpmiSetSegmentAccessRights : _funct
  152.  
  153.  
  154.  
  155.  
  156. ;/***************************************************************************\
  157. ;*
  158. ;* Function:    int dpmiCreateCodeAlias(unsigned codeSelector,
  159. ;*                  unsigned *selector);
  160. ;*
  161. ;* Description: Creates a data descriptor that has the same base and limit
  162. ;*              as a code segment descriptor. Use dpmiFreeDescriptor() to
  163. ;*              deallocate data descriptor.
  164. ;*
  165. ;* Input:       unsigned codeSelector   code segment selector
  166. ;*              unsigned *selector      pointer to data segment selector
  167. ;*
  168. ;* Returns:     MIDAS error code. New data selector is written to *selector.
  169. ;*
  170. ;\***************************************************************************/
  171.  
  172. GLOBAL  LANG dpmiCreateCodeAlias : _funct
  173.  
  174.  
  175.  
  176.  
  177. ;/***************************************************************************\
  178. ;*
  179. ;* Function:    int dpmiAllocDOSMem(unsigned numParagraphs, unsigned *segment,
  180. ;*                  unsigned *selector);
  181. ;*
  182. ;* Description: Allocates memory from DOS free memory pool, below 1MB. Use
  183. ;*              dpmiFreeDOSMem() to deallocate.
  184. ;*
  185. ;* Input:       unsigned numParagraphs  number of paragraphs to allocate
  186. ;*              unsigned *segment       pointer to real mode segment
  187. ;*              unsigned *selector      pointer to selector
  188. ;*
  189. ;* Returns:     MIDAS error code. Real mode segment of allocated block is
  190. ;*              written to *segment. Protected mode selector for block is
  191. ;*              written to *selector.
  192. ;*
  193. ;\***************************************************************************/
  194.  
  195. GLOBAL  LANG dpmiAllocDOSMem : _funct
  196.  
  197.  
  198.  
  199.  
  200. ;/***************************************************************************\
  201. ;*
  202. ;* Function:    dpmiFreeDOSMem(unsigned selector);
  203. ;*
  204. ;* Description: Deallocates memory allocated with dpmiAllocDOSMem().
  205. ;*
  206. ;* Input:       unsigned selector       selector for allocated block
  207. ;*
  208. ;* Returns:     MIDAS error code
  209. ;*
  210. ;\***************************************************************************/
  211.  
  212. GLOBAL  LANG dpmiFreeDOSMem : _funct
  213.  
  214.  
  215.  
  216.  
  217. ;/***************************************************************************\
  218. ;*
  219. ;* Function:    int dpmiRealModeInt(unsigned intNum,
  220. ;*                  dpmiRealCallRegs *registers);
  221. ;*
  222. ;* Description: Simulates a real mode interrupt using DPMI service 0x0300.
  223. ;*              *register MUST contain appropriate register values for
  224. ;*              interrupt (CS:IP is ignored).
  225. ;*
  226. ;* Input:       unsigned intNum                 interrupt number
  227. ;*              dpmiRealCallRegs *registers     DPMI real mode calling struct
  228. ;*
  229. ;* Returns:     MIDAS error code. Register values returned by the interrupt
  230. ;*              are written to *registers.
  231. ;*
  232. ;\***************************************************************************/
  233.  
  234. GLOBAL  LANG dpmiRealModeInt : _funct
  235.  
  236.  
  237.  
  238.  
  239. ;/***************************************************************************\
  240. ;*
  241. ;* Function:    int dpmiLockMemory(ulong start, ulong numBytes);
  242. ;*
  243. ;* Description: Locks a region of memory to prevent it from being paged. The
  244. ;*              memory can be unlocked using dpmiUnlockMemory().
  245. ;*
  246. ;* Input:       ulong start             memory region start address
  247. ;*              ulong numBytes          memory region length in bytes
  248. ;*
  249. ;* Returns:     MIDAS error code
  250. ;*
  251. ;\***************************************************************************/
  252.  
  253. GLOBAL  LANG dpmiLockMemory : _funct
  254.  
  255.  
  256.  
  257.  
  258. ;/***************************************************************************\
  259. ;*
  260. ;* Function:    int dpmiUnlockMemory(ulong start, ulong numBytes);
  261. ;*
  262. ;* Description: Unlocks a region of memory locked with dmpiLockMemory().
  263. ;*
  264. ;* Input:       ulong start             memory region start address
  265. ;*              ulong numBytes          memory region length in bytes
  266. ;*
  267. ;* Returns:     MIDAS error code
  268. ;*
  269. ;\***************************************************************************/
  270.  
  271. GLOBAL  LANG dpmiUnlockMemory : _funct
  272.  
  273.  
  274.  
  275.  
  276.  
  277. ;/***************************************************************************\
  278. ;*      enum dpmiFunctIDs
  279. ;*      -----------------
  280. ;* Description: ID numbers for DPMI functions
  281. ;\***************************************************************************/
  282.  
  283. ENUM    dpmiFunctIDs \
  284.         ID_dpmiAllocDescriptor = ID_dpmi, \
  285.         ID_dpmiFreeDescriptor, \
  286.         ID_dpmiSetSegmentBase, \
  287.         ID_dpmiSetSegmentLimit, \
  288.         ID_dpmiSetSegmentAccessRights, \
  289.         ID_dpmiCreateCodeAlias, \
  290.         ID_dpmiAllocDOSMem, \
  291.         ID_dpmiFreeDOSMem, \
  292.         ID_dpmiRealModeInt, \
  293.         ID_dpmiGetSegmentBase, \
  294.         ID_dpmiLockMemory, \
  295.         ID_dpmiUnlockMemory
  296.  
  297.  
  298. ;* $Log: dpmi.inc,v $
  299. ;* Revision 1.3  1997/01/16 18:41:59  pekangas
  300. ;* Changed copyright messages to Housemarque
  301. ;*
  302. ;* Revision 1.2  1996/05/30 22:38:46  pekangas
  303. ;* no changes?
  304. ;*
  305. ;* Revision 1.1  1996/05/22 20:49:33  pekangas
  306. ;* Initial revision
  307. ;*